package day24.edu;

import com.sun.source.tree.Tree;
import day20.edu.Person;
import org.junit.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

// Created: 24/09/2025, ChangJiang Ru
public class SetTest {
    @Test
    public void test1()
    {
        HashSet set = new HashSet();

        set.add("AA");
        set.add("BB");
        set.add("GreatFree");
        set.add(123);
        set.add(new Person("Tom", 12));

        Iterator iterator = set.iterator();
        while(iterator.hasNext())
        {
            System.out.println(iterator.next());
        }
    }
    
    @Test
    public void test2()
    {
        TreeSet treeSet = new TreeSet();

        treeSet.add("AA");
        treeSet.add("BB");
        treeSet.add("DD");
        treeSet.add("MM");

        Iterator iterator = treeSet.iterator();
        while(iterator.hasNext())
        {
            System.out.println(iterator.next());
        }
    }
}
